using FileTransfer.Client.Http.Model;

namespace FileTransferDesktop.Services;

public interface IAuthenticationService
{
    /// <summary>
    /// 当前用户信息
    /// </summary>
    UserResponse? CurrentUser { get; }

    /// <summary>
    /// 认证token
    /// </summary>
    string? Token { get; }

    /// <summary>
    /// 是否已登录
    /// </summary>
    bool IsAuthenticated { get; }

    /// <summary>
    /// 登录状态改变事件
    /// </summary>
    event EventHandler<bool>? AuthenticationStatusChanged;

    /// <summary>
    /// 登录
    /// </summary>
    /// <param name="username">用户名或邮箱</param>
    /// <param name="password">密码</param>
    /// <param name="rememberMe">记住登录状态</param>
    /// <returns>登录结果</returns>
    Task<AuthResponse> LoginAsync(string username, string password, bool rememberMe = false);

    /// <summary>
    /// 用户注册
    /// </summary>
    /// <param name="username">用户名</param>
    /// <param name="email">邮箱</param>
    /// <param name="password">密码</param>
    /// <param name="displayName">显示名称</param>
    /// <returns>注册结果</returns>
    Task<AuthResponse> RegisterAsync(string username, string email, string password, string displayName = "");

    /// <summary>
    /// 登出
    /// </summary>
    Task LogoutAsync();

    /// <summary>
    /// 获取当前用户信息
    /// </summary>
    /// <returns>用户信息</returns>
    Task<UserResponse?> GetCurrentUserAsync();

    /// <summary>
    /// 从存储中恢复登录状态
    /// </summary>
    Task<bool> RestoreAuthenticationAsync();    /// <summary>
                                                /// 获取最后一次登录的用户名
                                                /// </summary>
                                                /// <returns>最后登录的用户名，如果没有则返回null</returns>
    string? GetLastLoginUser();

    /// <summary>
    /// 刷新当前用户信息
    /// </summary>
    /// <returns>刷新成功返回true，失败返回false</returns>
    Task<bool> RefreshCurrentUserAsync();
}
